package com.generator.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.common.annotation.LogInfo;
import com.generator.dto.ValueRuleDto;
import com.generator.entity.ValueRule;
import com.generator.service.ValueRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/generator/valueRule")
@Api(value = "后台value_rule控制层",tags = {"后台value_rule控制层"})
@LogInfo
public class ValueRuleController {

    @Autowired
    private ValueRuleService valueRuleService;

    /**
     * 查询所有记录
     *
     */
    @ApiOperation("查询value_rule分页记录接口")
    @GetMapping("/list")
    public ResponseEntity list(Page pageDto,ValueRule valueRule ) {
        return valueRuleService.list(pageDto,valueRule);
    }

     
    /**
     * 新增，忽略null字段
     *@param valueRule 新增的记录
     *
     */
    @ApiOperation("保存或更新value_rule记录接口")
    @PostMapping("/save")
    public ResponseEntity save(@Valid @RequestBody ValueRuleDto valueRule) {
        return valueRuleService.save(valueRule);
    }
    @ApiOperation("获取value_rule记录通过数据库配置和列名接口")
    @GetMapping("/getcolumnvalueRule/{id}/{column}")
    public ResponseEntity getcolumnvalueRule(@PathVariable("id") String id,@PathVariable("column")String column) {
         return valueRuleService.getcolumnvalueRule(id, column);
    }

    /**
     * 批量删除
     * @param ids
     * 
     */
    @ApiOperation("批量删除value_rule记录接口")
    @DeleteMapping("/del")
    public ResponseEntity delAll(@RequestBody List<Integer> ids) {
        return valueRuleService.delAll(ids);
    }
    
}